package com.example.mybatisplusdemo.web.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mybatisplusdemo.model.domain.Favorite;
import com.example.mybatisplusdemo.model.vo.AuditMessageVO;
import org.springframework.web.bind.annotation.RequestMapping;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.mybatisplusdemo.common.JsonResponse;
import com.example.mybatisplusdemo.service.IAuditMessageService;
import com.example.mybatisplusdemo.model.domain.AuditMessage;
import com.example.mybatisplusdemo.model.dto.PageDTO;


/**
 *
 *  前端控制器
 *
 *
 * @author lxp
 * @since 2025-07-05
 * @version v1.0
 */
@RestController
@RequestMapping("/api/auditMessage")
public class AuditMessageController {

    private final Logger logger = LoggerFactory.getLogger(AuditMessageController.class);

    @Autowired
    private IAuditMessageService auditMessageService;

    @GetMapping("getById")
    public JsonResponse getById(Long id) {
        AuditMessage auditMessage = auditMessageService.getById(id);
        return JsonResponse.success(auditMessage);
    }

    @GetMapping("addAuditMessage")
    public JsonResponse addAuditMessage(AuditMessage auditMessage) {
        boolean result = auditMessageService.save(auditMessage);
        return JsonResponse.success(result);
    }

    // 分页查询审核消息
    @GetMapping("listPagingAuditMessagesByMerchantIdWithStoreInfo")
    public JsonResponse listPagingAuditMessagesByMerchantIdWithStoreInfo(PageDTO pageDTO, Long merchantId) {
        Page<AuditMessageVO> page = auditMessageService.listPagingAuditMessagesByMerchantIdWithStoreInfo(pageDTO, merchantId);
        return JsonResponse.success(page);
    }

    @GetMapping("deleteById")
    public JsonResponse deleteById(Long id) {
        boolean isDeleted = auditMessageService.removeById(id);
        return JsonResponse.success(isDeleted);
    }
}

